package com.leancloud.login.activity;

import android.os.Bundle;
import android.support.v4.BuildConfig;
import android.view.View;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.aries.ui.view.title.TitleBarView;
import com.leancloud.login.LoginPath;
import com.leancloud.login.R;

import tech.com.commoncore.base.BaseTitleActivity;
import tech.com.commoncore.utils.DataUtils;

import static com.leancloud.login.LoginPath.LOGIN_PRIVACY_AGREEMENT;
import static com.leancloud.login.LoginPath.LOGIN_REGISTRATION_AGREEMENT;

@Route(path = LoginPath.LOGIN_ABOUT)
public class AboutActivity extends BaseTitleActivity implements View.OnClickListener {
    TextView versionCodeText, introductionText;

    @Override
    public void setTitleBar(TitleBarView titleBar) {
        titleBar.setTitleMainText("关于我们").setBackground(getResources().getDrawable(R.drawable.btn_jb));
    }

    @Override
    public int getContentLayout() {
        return R.layout.activity_about;
    }

    @Override
    public void initView(Bundle savedInstanceState) {
        versionCodeText = findViewById(R.id.version_code_text);
        introductionText = findViewById(R.id.introduction_text);

        findViewById(R.id.registration_agreement_tx).setOnClickListener(this);
        findViewById(R.id.privacy_agreement_tx).setOnClickListener(this);

        setData();
    }

    private void setData() {
        versionCodeText.setText(BuildConfig.VERSION_NAME);
        String introduction = "";//getResources().getString(R.string.string_introduction);
        introductionText.setText(DataUtils.toSBC(introduction));
    }

    @Override
    public void onClick(View v) {
        if (v.getId() == R.id.privacy_agreement_tx) {
            ARouter.getInstance().build(LOGIN_PRIVACY_AGREEMENT).greenChannel().navigation();
        } else if (v.getId() == R.id.registration_agreement_tx) {
            ARouter.getInstance().build(LOGIN_REGISTRATION_AGREEMENT).greenChannel().navigation();
        }
    }
}
